package com.zy.explore.design.interfaces.facade.v1;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.zy.explore.design.patterns.templatemethod.MerchantA;
import com.zy.explore.design.patterns.templatemethod.MerchantB;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * description 模板方法模式示例Facade
 *
 * @author 🇨🇳中国印🇨🇳
 * @date 2021年05月15日 14:27
 */
@Api(tags = {"模板方法模式示例Facade"})
@RestController
@RequestMapping("/template")
public class TemplateMethodFacade {

    @Resource
    private MerchantA merchantA;

    @Resource
    private MerchantB merchantB;

    @ApiOperationSupport(order = 10, author = "🇨🇳中国印🇨🇳")
    @ApiOperation("模板方法商户A")
    @PostMapping("/useTemplateMethod1")
    public Integer useTemplateMethod1(HttpServletRequest request, HttpServletResponse response) {
        merchantA.handle(request, response);
        return 1;
    }

    @ApiOperationSupport(order = 20, author = "🇨🇳中国印🇨🇳")
    @ApiOperation("模板方法商户B")
    @PostMapping("/useTemplateMethod2")
    public Integer useTemplateMethod2(HttpServletRequest request, HttpServletResponse response) {
        merchantB.handle(request, response);
        return 1;
    }
}
